﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.BLL;
using KMFrame.Core;

namespace SzCourt.WebSite.shenwu
{
    public partial class zxlist : System.Web.UI.Page
    {
        public int PageIndex = 1;
        public int PageSize = 10;
        public int TotalPage = 1;
        public string Keyword = string.Empty;
        private string _Type = string.Empty;
        private string _TabName = "通过当事人查询";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                getList();
            }
        }

        private void getList()
        {
            this.PageIndex = string.IsNullOrEmpty(Request.QueryString["PageIndex"]) ? 1 : Convert.ToInt32(Request.QueryString["PageIndex"]);
            this.Keyword = string.IsNullOrEmpty(Request.QueryString["keyword"]) ? "" : Request.QueryString["keyword"];
            this._Type = string.IsNullOrEmpty(Request.QueryString["type"]) ? "" : Request.QueryString["type"];
            this.txtKeyword.Value = this.Keyword;

            CarryOutCondition param = new CarryOutCondition();
            param.PageIndex = this.PageIndex;
            param.PageSize = this.PageSize;
            if (this.Keyword.Length > 0)
            {
                param.KeyWord = this.Keyword;
            }
            if (this._Type.Length > 0)
            {
                switch (this._Type)
                {
                    case "Parties":
                        this._TabName = "通过当事人查询";
                        param.Type = QueryType.Parties;
                        break;
                    case "SrcCaseName":
                        this._TabName = "通过原审案号查询";
                        param.Type = QueryType.SrcCaseName;
                        break;
                    case "CaseSerial":
                        this._TabName = "通过流水号查询";
                        param.Type = QueryType.CaseSerial;
                        break;
                    case "CaseName":
                        this._TabName = "通过执行案号查询";
                        param.Type = QueryType.CaseName;
                        break;
                    default:
                        this._TabName = "通过当事人查询";
                        param.Type = QueryType.Parties;
                        break;
                }
            }

            CarryOut bll = new CarryOut();
            PageResult result = (PageResult)bll.GetCarryOutPage(param);

            if (result != null)
            {
                this.rptDataList.DataSource = result.ResultList;
                this.rptDataList.DataBind();

                this.pager1.RecordCount = result.TotalCount; //实际的库存数量
                this.pager1.TotalPage = result.PageCount;
                this.pager1.PageIndex = this.PageIndex;
                this.pager1.PageSize = this.PageSize;
                this.pager1.LinkUrl = "/shenwu/zxlist.aspx?PageIndex=" + this.PageIndex.ToString() + "&keyword="+ Server.UrlEncode(this.Keyword)+"&type="+this._Type;
                this.pager1.IsResult = false;
            }

            this.tabName.InnerText = this._TabName;

        }

    }
}